package br.upe.dsc.caeto.core.hierarchy;

import br.upe.dsc.caeto.core.IRegister;
import br.upe.dsc.caeto.core.InvalidElementException;
import br.upe.dsc.caeto.core.cacheunit.CacheUnit;
import br.upe.dsc.caeto.core.cacheunit.CacheUnitRegister;
import br.upe.dsc.caeto.core.cacheunit.CacheUnitRepositoryList;

public class Hierarchy implements Cloneable {

	public static final String HIERARCHY_1 = "hierarchy1";
	public static final String HIERARCHY_2 = "hierarchy2";
	public static final String HIERARCHY_3 = "hierarchy3";
	public static final String HIERARCHY_4 = "hierarchy4";
	public static final String HIERARCHY_5 = "hierarchy5";
	
	private IRegister<CacheUnit> cacheUnits;
	private String tensaoAlimentacao;
	private String transistorTechnology;
	private String name;
	
	public Hierarchy() {
		
	}
	
	public Hierarchy(String name, String tensaoAlimentacao,
			String transistorTechnology) {
		
		this.name = name;
		this.tensaoAlimentacao = tensaoAlimentacao;
		this.transistorTechnology = transistorTechnology;
		this.cacheUnits = new CacheUnitRegister(new CacheUnitRepositoryList());
	}
	
	public String getName() {
		return name;
	}

	public void setName(String nome) {
		this.name = nome;
	}

	public String getTransistorTechnology() {
		return transistorTechnology;
	}

	public void setTransistorTechnology(String transistorTechnology) {
		this.transistorTechnology = transistorTechnology;
	}

	public String getTensaoAlimentacao() {
		return tensaoAlimentacao;
	}

	public void setTensaoAlimentacao(String tensaoAlimentacao) {
		this.tensaoAlimentacao = tensaoAlimentacao;
	}
	
	public void addCacheUnit(CacheUnit cache) throws InvalidElementException {
		this.cacheUnits.add(cache);
	}

	public IRegister<CacheUnit> getCacheUnits() {
		return this.cacheUnits;
	}
	
	public void setCacheUnits(IRegister<CacheUnit> cacheUnits) {
		this.cacheUnits = cacheUnits;
	}
	
	public Object clone() {
		try {
			Hierarchy clone = (Hierarchy) super.clone();
			clone.setCacheUnits(this.cacheUnits);
			return clone;
		} catch (CloneNotSupportedException e) {
			return null;
		}
	}
}
